<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="login.css">
        <script src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
    $(function(){
            $(".login").on('click',function(){
                var user = $(".user").val();
                var pass = $(".pass").val();
                if(user==""){
                    $("h2").html("user不能为空");
                    $(".user").focus();
                    return false;
                }
                if(pass==""){
                    $("h2").html("<b>pass不能为空</b>");
                    $(".pass").focus();
                    return false;
                }
                $.ajax({
                    url:'logincheck.php',
                    type:'post',
                    dataType:'json',
                    data:{user:user,pass:pass},
                    success:function(msg){

                        $("h2").text(msg.str);
                        if(msg.status==100){

                        window.location.href = 'admin.php';

                    }else if(msg.status==2){
                        $(".user").focus().select();
                    }else{
                        $(".pass").focus().select();
                    }
                    }
                });
            });

    });
    </script>
</head>
<body>

    <div class="wrapper">
    <h1 style="text-align:center">新闻后台管理网站</h1>
    <div class="loginBox">
        <div class="loginBoxCenter">
            <p><label for="username">用户名：</label></p>
            <p><input type="text" name="user" class="user" autofocus="autofocus" required="required" autocomplete="off" placeholder="请输入用户名" value="user" /></p>
            
            <p><input type="password" id="password" name="pass" class="pass" required="required" placeholder="请输入密码" value="pass" /></p>
        </div>
        <div class="loginBoxButtons">
            
            <button class="login">登录</button>
        </div>
        <h2></h2>
    </div>
    
</div>
</body>
</html>